package com.zjlanyun.erp.rfid.m10.u8.activity;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;

import com.zjlanyun.erp.MainApplication;
import com.zjlanyun.erp.R;
import com.zjlanyun.erp.utils.Toastor;
import com.zjlanyun.erp.view.BaseSwipeBackActivity;


public class SessionActivity extends BaseSwipeBackActivity {

    Button setSession = null;
    Spinner spin_Session = null;
    Spinner spin_Flag = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.rfid_setting_session);
        ((MainApplication) getApplication()).addActivity(this);
        initBaseView();

        title.setText("盘询参数");
        setSession = (Button) findViewById(R.id.setSession);
        spin_Session = (Spinner) findViewById(R.id.spinner_Session);
        spin_Flag = (Spinner) findViewById(R.id.spinner_Flag);

        String[] mItems = {"s0", "s1", "s2", "s3"};
        String[] mItemsFlag = {"A", "B"};
        ArrayAdapter<String> _Adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mItems);
        spin_Session.setAdapter(_Adapter);
        _Adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mItemsFlag);
        spin_Flag.setAdapter(_Adapter);

        spin_Session.setSelection(MainApplication.getSessionState());
        spin_Flag.setSelection(MainApplication.getFlagState());

        setSession.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                int index = spin_Session.getSelectedItemPosition();
                MainApplication.saveSessionState(index);
                index = spin_Flag.getSelectedItemPosition();
                MainApplication.saveFlagState(index);
                Toastor.getInstance().showShortToast("参数设置成功");
            }
        });
    }
}
